package de.pass.ch.graph.edge;

import java.io.Serializable;

public class SimpleEdge implements Serializable {

	private static final long serialVersionUID = -6754767300338690223L;

	private int target;
	private int weight;

	public SimpleEdge(int t, int w, boolean f, boolean b) {
		target = t;
		weight = w;
		if (f) {
			target = target | Integer.MIN_VALUE;
		} else {
			target = target & Integer.MAX_VALUE;
		}
		if (b) {
			target = target | (0x1 << 30);
		} else {
			target = target & (~(0x1 << 30));
		}
	}

	public int getTarget() {
		return target & (Integer.MAX_VALUE >> 1);
	}

	public int getWeight() {
		return weight;
	}

	public boolean isForward() {
		return (target & Integer.MIN_VALUE) != 0;
	}

	public boolean isBackward() {
		return (target & (0x1 << 30)) != 0;
	}

}
